<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
        hello js
        <hr>
        <input type="button" value="按钮" onclick="method01()">
</body>
<script>
    function method01() {
        var result=confirm("你常年了吗");
        if (result){
            location.href="http://www.baidu.com"
        }

    }
</script>
</html>